package com.gxa.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author: 42818
 * @date: 2022/8/31 17:24
 * @Software: IntelliJ IDEA
 * @Package_Name: com.gxa.utils
 * @ClassName: ResponseData
 * @Description:
 **/

@ApiModel("响应结果实体类")
public class ResponseData {

    @ApiModelProperty("响应结果编号")
    private int code;

    @ApiModelProperty("响应结果信息")
    private String msg;

    @ApiModelProperty("查询结果总数")
    private int count;

    @ApiModelProperty("响应结果数据")
    private Object data;

    public ResponseData() {
    }

    public ResponseData(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseData(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseData(int code, String msg, int count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResponseData successData(Object data){

        ResponseData responseData = new ResponseData();
        responseData.setData(data);

        return responseData;
    }

    public static ResponseData error(int code,String msg){

        ResponseData responseData = new ResponseData();
        responseData.setCode(code);
        responseData.setMsg(msg);
        return responseData;
    }
}
